/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.esakk001;

import idea.model.qnrlibrary.Categories;
import idea.model.qnrlibrary.CommonParameters;
import org.openide.ErrorManager;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.nodes.Node;
import org.openide.nodes.PropertySupport;
import org.openide.nodes.Sheet;
import org.openide.util.lookup.Lookups;

/**
 *
 * @author esakk001
 */
public class CategoriesNode extends AbstractNode {

        public CategoriesNode(Categories cp) {
            super(Children.LEAF, Lookups.fixed(new Object[]{
                        cp
                    }));
            
            this.setDisplayName(cp.getCategory());
        }

        @Override
        protected Sheet createSheet() {
            Sheet sheet = Sheet.createDefault();
            Sheet.Set set = Sheet.createPropertiesSet();
            CommonParameters cp = getLookup().lookup(CommonParameters.class);

            try {
                PropertySupport.Reflection cpId = new PropertySupport.Reflection(cp, String.class, "getCommonParametersId", null);
                Node.Property cpName = new PropertySupport.Reflection(cp, String.class, "getParameterName", "setParameterName");
                Node.Property cpValue = new PropertySupport.Reflection(cp, String.class, "getParameterValue", "setParameterValue");
                Node.Property cpDesc = new PropertySupport.Reflection(cp, String.class, "getParamDescription", "setParamDescription");

                cpId.setName("ID");
                cpName.setName("Name");
                cpValue.setName("Value");
                cpDesc.setName("Description");

                set.put(cpId);
                set.put(cpName);
                set.put(cpValue);
                set.put(cpDesc);
            } catch (Exception e) {
                ErrorManager.getDefault();
            }

            sheet.put(set);
            return sheet;
        }
    }
